package com.zzyl.nursing.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import com.zzyl.nursing.domain.NursingTask;
import org.apache.ibatis.annotations.Select;

/**
 * 护理任务Mapper接口
 * 
 * @author alexis
 * @date 2024-11-17
 */
@Mapper
public interface NursingTaskMapper extends BaseMapper<NursingTask>
{
    /**
     * 查询护理任务
     * 
     * @param id 护理任务主键
     * @return 护理任务
     */
    public NursingTask selectNursingTaskById(Long id);

    /**
     * 查询护理任务列表
     * 
     * @param nursingTask 护理任务
     * @return 护理任务集合
     */
    public List<NursingTask> selectNursingTaskList(NursingTask nursingTask);

    /**
     * 新增护理任务
     * 
     * @param nursingTask 护理任务
     * @return 结果
     */
    public int insertNursingTask(NursingTask nursingTask);

    /**
     * 修改护理任务
     * 
     * @param nursingTask 护理任务
     * @return 结果
     */
    public int updateNursingTask(NursingTask nursingTask);

    /**
     * 删除护理任务
     * 
     * @param id 护理任务主键
     * @return 结果
     */
    public int deleteNursingTaskById(Long id);

    /**
     * 批量删除护理任务
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteNursingTaskByIds(Long[] ids);

    /**
     * 根据id查询护理员姓名
     * @param id
     * @return
     */
    @Select("select GROUP_CONCAT(s.nick_name SEPARATOR ', ') as nursingName from nursing_task n left join sys_user s on FIND_IN_SET(s.user_id, n.nursing_id) > 0 where n.id = #{id} group by n.id")
    String getNursingNameById(Long id);

    /**
     * 根据id查询老人身份证号
     * @param id
     * @return
     */
    @Select("select e.id_card_no from nursing_task n right join elder e on n.elder_id = e.id where n.id = #{id}")
    String selectElderIdcardById(Long id);

    @Select("select nick_name from sys_user where user_id = #{userId}")
    String selectUserName(Long userId);

    @Select("select nl.name from nursing_level nl left join nursing_project_plan npp on nl.lplan_id = npp.plan_id where npp.project_id = #{projectId}")
    String getNursingLevelNameByProjectId(Integer projectId);
}
